<template>
    <el-dialog :title="title" :visible.sync="dialogVisible" width="1000px">
        <div>
            <div>
                <!-- <el-form :model="queryParams" ref="queryForm" v-show="showSearch" inline label-width="70px"> -->
                    <!-- <el-form-item label="时间" prop="customDate">
                        <el-radio-group v-model="queryParams.customDate" @change="changeCustomDate">
                            <el-radio-button :label="1">今天</el-radio-button>
                            <el-radio-button :label="2">昨天</el-radio-button>
                            <el-radio-button :label="3">近7天</el-radio-button>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item label="日期" prop="date">
                        <el-date-picker v-model="queryParams.date" format="yyyy-MM-dd" type="daterange" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 240px;"></el-date-picker>
                    </el-form-item> -->
                    <!-- <el-form-item label=" ">
                        <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
                        <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
                    </el-form-item> -->
                <!-- </el-form> -->
            </div>
            <div>
                <el-row :gutter="10" class="mb8">
                    <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
                </el-row>
                <el-table v-loading="loading" :data="tableData" border script>
                    <el-table-column label="订单号" prop="name"></el-table-column>
                    <el-table-column label="争议状态" prop="disputeapi_status"></el-table-column>
                    <el-table-column label="支付通道" prop="disputeapi_type"></el-table-column>
                </el-table>
            </div>
            <pagination v-show="total > 0" :total="total" :page.sync="pageInfo.page" :limit.sync="pageInfo.limit" @pagination="getList" />
        </div>
        <div slot="footer" class="dialog-footer"></div>
    </el-dialog>
</template>

<script>
import { queryDisputeInfo } from '@/api/order'
export default {
    name: 'DetailDialog',
    components: {},
    props: {
        value: {
            type: Boolean,
            default: false,
            required: true,
        },
        params: {
            type: Object,
            default: () => {},
        },
    },
    data() {
        return {
            loading: false,
            showSearch: true,
            // 总条数
            total: 0,
            // 表格数据
            tableData: [],
            pageInfo: {
                page: 1,
                limit: 10,
            },
            // 查询参数
            queryParams: {
                date: [],
                customDate: 0
            },
        }
    },
    computed: {
        title() {
            return `争议订单明细`
        },
        dialogVisible: {
            get() {
                return this.value
            },
            set(val) {
                this.$emit('input', val)
            },
        },
    },

    created() {
        this.queryParams.timedate = this.params.timedate
        this.queryParams.type = this.params.type
        this.getList()
    },
    methods: {
        changeCustomDate() {
            this.queryParams.date = []
            this.handleQuery()
        },
        // 搜索按钮操作
        handleQuery() {
            this.pageInfo.page = 1
            this.getList()
        },

        // 重置按钮操作
        resetQuery() {
            this.resetForm('queryForm')

            this.handleQuery()
        },
        getList() {
            this.loading = true
            queryDisputeInfo({ 
                ...this.pageInfo,
                timedate: this.queryParams.timedate,
                type: this.queryParams.type
            })
                .then(res => {
                    // this.tableData = res.data??[]
                    this.tableData = res.data?.list ?? []
                    this.total = res.data?.total ?? 0
                })
                .finally(() => {
                    this.loading = false
                })
        },
    },
}
</script>

<style></style>
